import { useState } from "react"

const useHooks = (options) => {
    const { url } = options;
    const [data, setData] = useState({});
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState(null);
    const send = async () => {
        setLoading(true);
        try {
            const data = await fetch(url);
            console.log(data)
            const res = await data.json();
            console.log(res)
            setData(res);
            setLoading(false);
        } catch(e) {
            setError(e);
            setLoading(false);
        }
    }
    return {
        data,
        loading,
        error,
        send
    }
}

export default useHooks